<template>
  <div>
    <h1>mapMutations</h1>
    <p>count: {{$store.state.count}}</p>
    <p>msg: {{$store.state.msg}}</p>
    <!-- 引入mapMutations，执行 store.mutations 的方法 -->
    <button @click="add">+</button>
    <button @click="reduce">-</button>
    <button @click="addStr(666)">add666</button>
  </div>
</template>
<script>
  import { mapMutations } from 'vuex'
  export default {
    methods: {
      ...mapMutations([
        'reduce', // 映射 this.reduce() 为 this.$store.commit('reduce')
        'add', // 映射 this.add() 为 this.$store.commit('add')
        'addStr'
      ]),
    }
    /*methods:  mapMutations([ // 简写
     'add','reduce'
     ]),*/
  }
</script>


